package com.api.gbhg.liuwenbo.test;

import com.api.gbhg.liuwenbo.api.BudgetSectionItemListApi;
import com.api.gbhg.liuwenbo.pojo.BudgetSection;
import weaver.general.Util;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description
 * @Author
 * @Date
 */
public class test11_8 {

    static{
        System.out.println("11");
    }

    public static void main(String[] args) {
        String a = "4";
        String b = a.equals("8") || a.equals("5")?"对":"错";
        System.out.println(b);

        List<String> list = new ArrayList<>();
        list.add("formtable_main_59_dt1");
        list.add("formtable_main_59_dt2");
        list.add("formtable_main_59_dt3");

        System.out.println(!"".isEmpty()+"111111111111");

        String s = joinDtSumSql(list,"64");
        System.out.println(s);

        BigDecimal bg1 = new BigDecimal("1000.00");
        BigDecimal bg2 = new BigDecimal("0");
        System.out.println(bg1.add(bg2).toString());
        Map<String,Object> map = new HashMap<>();
        if (map.containsKey("a")){
            System.out.println("aaa");
        }

    }

    public static String joinDtSumSql(List<String> list,String mainid){
        StringBuilder field = new StringBuilder();
        StringBuilder dTab = new StringBuilder();

        if (list.size() == 1){
            field.append("sum(zfcgfwy) zfcgfwy");
            dTab.append(list.get(0));
        }else{
            for (int i = 0; i < list.size(); i++) {
                if (i==0){
                    field.append("sum(isnull(a"+i+".zfcgfwy,0)+");
                    dTab.append(list.get(i)+" a"+i+" full join ");
                }else{
                    field.append("isnull(a"+i+".zfcgfwy,0)+");
                    dTab.append(list.get(i)+" a"+i+" on a"+(i-1)+".mainid =a"+i+".mainid full join ");
                }

            }
        }
        return "select "+field.substring(0,field.length()-1)+") from "+dTab.substring(0,dTab.length() - 10)+" where a0.mainid ="+mainid+" ";
    }
}
